package com.tender.utils;

import org.jasypt.encryption.StringEncryptor;
import org.jasypt.util.text.AES256TextEncryptor;
import org.jasypt.util.text.BasicTextEncryptor;

/**
 * @see BasicTextEncryptor
 * @see StringEncryptor
 */
public class EncryptorUtils {

    public static void main(String[] args) {
        // BasicTextEncryptor 的默认加密算法为： PBEWithMD5AndDES
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
        // 这个是加密的盐
        textEncryptor.setPassword("jg1HwtUwkFIN7HSV");
        String userName = textEncryptor.encrypt("ytportnet");
        String passWord = textEncryptor.encrypt("server1007");

        System.out.println("------------------ 加密操作 ------------------");
        System.out.println("userName加密后 = " + userName);
        System.out.println("passWord加密后 = " + passWord);

        System.out.println("------------------ 解密操作 ------------------");
        System.out.println("userName解密后 = " + textEncryptor.decrypt(userName));
        System.out.println("passWord解密后 = " + textEncryptor.decrypt(passWord));
    }

//    public static void main(String[] args) {
//        // BasicTextEncryptor 的默认加密算法为： PBEWithMD5AndDES
//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//        // 这个是加密的盐
//        textEncryptor.setPassword("csair.fly");
//        String userName = "app";
//        String passWord = "MyApple12!_789";
//
//        userName = textEncryptor.encrypt(userName);
//        passWord = textEncryptor.encrypt(passWord);
//
//        System.out.println("userName加密后 = " + userName);
//        System.out.println("passWord加密后 = " + passWord);
//
//        System.out.println("------------------ 解密操作 ------------------");
//        System.out.println("userName解密后 = " + textEncryptor.decrypt(userName));
//        System.out.println("passWord解密后 = " + textEncryptor.decrypt(passWord));
//    }

//    public static void main(String[] args) {
//        // BasicTextEncryptor 的默认加密算法为： PBEWithMD5AndDES
//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//        // 这个是加密的盐
//        textEncryptor.setPassword("csair.fly");
//        String userName = "G/PjSKXlRQT25FOIGgfc+A==";
//        String passWord = "eXaJh4SDy9LloTM/SSdAFM3M+G1pzU6+";
//
//        System.out.println("------------------ 解密操作 ------------------");
//        System.out.println("userName解密后 = " + textEncryptor.decrypt(userName));
//        System.out.println("passWord解密后 = " + textEncryptor.decrypt(passWord));
//    }

    /**
     * @see StringEncryptor
     * @see StringEncryptor
     * @param args
     */
//    public static void main(String[] args) {
//        String salt = "Cop*963.test";
//        String mi_name = "MFy0vAEU0Csff0Hrik95/QO+PkuS2Dtz";
//        String mi_password = "PK9uve8aN3vFznsy+6kvpGQSjdFMjhp4ooFUMdFnOsE=";
//
//        AES256TextEncryptor textEncryptor = new AES256TextEncryptor();
//        textEncryptor.setPassword(salt);
//        String username = textEncryptor.decrypt(mi_name);
//        String password = textEncryptor.decrypt(mi_password);
//
//        System.out.println("username = " + username);
//        System.out.println("password = " + password);
//    }


}
